package com.qianbao.controller.v1.xianwan;


import com.qianbao.components.excepion.CommonException;
import com.qianbao.components.svversion.ApiVersion;
import com.qianbao.domain.xianwan.XianWanEntity;
import com.qianbao.service.xianwan.XianWanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

@Controller
@ApiVersion(1)
@RequestMapping("/xianwancenter/{version}/")
public class XianWanController {

    @Autowired
    private XianWanService service;


    @RequestMapping("/xianwan-reward-callback")
    @ResponseBody
    public HashMap<String,String> xianwanRewardCallBack(XianWanEntity entity){


        try {
            service.saveDeviceOrder(entity);

            HashMap<String, String> map = new HashMap<>();
            map.put("success","1");
            map.put("message","接收成功");
            return map;

        } catch (CommonException e) {

            HashMap<String, String> map = new HashMap<>();
            map.put("success",String.valueOf(e.getCode()));
            map.put("message",e.getMessage());
            return map;
        }

    }










}
